package persistence;

import core.Container;
import core.ProductGroup;
/**
 * the data transfer object for containers
 * @author Sabrina
 *
 */
public class ContainerDTO 
{
	private Container _container;
	/**
	 * construct the container DTO
	 * @param container
	 */
	public ContainerDTO(Container container)
	{
		assert(container != null);
		_container = container;
		
	}
	
	/**
	 * Gets the ID of the associated container
	 * @return the container's ID
	 */
	public int getContainerID()
	{
		return _container.getID();
	}
	
	/**
	 * Gets the name of the associated container
	 * @return the container's name
	 */
	public String getContainerName()
	{
		return _container.getName();
	}
	
	/**
	 * Gets the parent of the associated container
	 * 
	 * @return the parent container, note: returns null if no parent container
	 */
	public Container getContainerParent()
	{
		return _container.getParent();
	}
	
	/**
	 * gets the value of the container's three-month supply
	 * @return the value of the 3-month supply or 0 if this is not a product group
	 */
	public float getThreeMonthSupplyValue()
	{
		if (_container instanceof ProductGroup)
			return  ((ProductGroup)_container).getThreeMonthSupply().getQuantity();
		else
			return 0;
	}
	
	/**
	 * gets the unit of the container's three-month supply
	 * @return the unit of the 3-month supply or "" if this is not a product group
	 */
	public String getThreeMonthSupplyUnit()
	{
		if (_container instanceof ProductGroup)
			return  ((ProductGroup)_container).getThreeMonthSupply().getUnit().toString();
		else
			return "";
	}
	
	public int getParentID(){
		assert(_container.getParent() != null);
		return _container.getParent().getID();
	}
	
	public void setContainerID(int id){
		_container.setID(id);
	}
}
